package com.ny.service.Impl;

import com.ny.entity.Reservations;
import com.ny.mapper.ReservationMapper;
import com.ny.service.ReservationService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ReservationServiceImpl implements ReservationService {
    @Autowired
    private ReservationMapper reservationMapper;
    @Override
    public void addReservation(Reservations reservation) {
        reservationMapper.addReservation(reservation);
    }

    //管理员数据库查询操作
    @Override
    public List<Reservations> findAllReservations() {
        return reservationMapper.findAllReservations();
    }

    //管理员审批
    public void updateReservationStatus(int reservationId, String status, String rejectReason) {
        reservationMapper.updateReservationStatus(reservationId, status, rejectReason);
    }




    //多条件查询教室

//    public List<Classrooms> searchReservation(String classroomName, String startTime, String endTime, String status) {
//        return reservationMapper.searchReservation(classroomName, startTime,endTime, status);
//    }
    @Override
    public List<Reservations> searchReservation(String classroomName, String startTime, String endTime, String status) {
        // 这里可以根据具体需求，对传入的参数进行一些预处理或者验证等操作
        // 例如，如果 startTime 和 endTime 是字符串格式的日期时间，可能需要转换为合适的日期时间对象来传递给 MyBatis 查询

        // 调用 MyBatis 的 Mapper 接口方法进行查询，传递参数并获取结果列表
        return reservationMapper.searchReservation(classroomName, startTime, endTime, status);
    }

}
